﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.DBM; 

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class ES_MoveRequest2 : System.Web.UI.UserControl
    {
        private SsMng ssMng = new SsMng();
        private object _dataItem = null;

        protected void Page_Load(object sender, EventArgs e)
        {

      
      
        }


        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            if (!IsUserControlPostBack)
            {

                //lblEmpSeq.Text = ssMng.EmpSeq;
                //lblCreateWhen.Text = DateTime.Today.ToString();
              
                //UpperComboBLL objCB = new UpperComboBLL();
                //DataTable dt;
                //dt = objCB.select();
                //cbUpper.DataSource = dt;
                //cbUpper.DataBind();
                //cb.DataSource = objCB.select();
                this.ViewState.Add("IsUserControlPostBack", true);
            }

            if (DataItem != null)
            {
                if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
                {
                    // lblSeq.Text = DataBinder.Eval(DataItem, "req_seq").ToString();
                    no_seq.Text = DataBinder.Eval(DataItem, "no_seq").ToString();
                    txtRemark.Text = DataBinder.Eval(DataItem, "remarks").ToString();
                   cbUpper.SelectedValue = DataBinder.Eval(DataItem, "approved_seq").ToString();
              lblReqSeq.Text = DataBinder.Eval(DataItem, "req_seq").ToString();




                    this.btnAddnew.Visible = false;
                    this.btnUpdate.Visible = true;
                }
                else
                {
                    this.btnUpdate.Visible = false;
                    this.btnAddnew.Visible = true;
                }

                  }
        }





        protected bool IsUserControlPostBack
        {
            get
            {
                return this.ViewState["IsUserControlPostBack"] != null;
            }
        }


        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }
        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            MoveRequestBLL obj = new MoveRequestBLL();

            string seq;
            seq = no_seq.Text.ToString();
            int approve_seq;
            approve_seq = int.Parse(cbUpper.SelectedValue);
            obj.Insert_hrm_es_move_requests(Convert.ToInt32(lblEmpSeq.Text),no_seq.Text ,  approve_seq, cbUpper.Text, txtRemark.Text, 1);         
                   
                      
        }


        protected void btnUpdate_Click(object sender, EventArgs e)
        {

             int approve_seq;
            approve_seq = int.Parse(cbUpper.SelectedValue);
            MoveRequestBLL obj = new MoveRequestBLL();
            obj.Update_hrm_es_move_requests(int.Parse(lblReqSeq.Text),no_seq.Text ,int.Parse(cbUpper.SelectedValue.ToString()),cbUpper.SelectedItem.ToString()  , txtRemark.Text, 1);       
            
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }
    }
}